import 'package:flutter/material.dart';

class Demo3 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new Demo3State();
  }
}

class Demo3State extends State<Demo3> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('堆叠布局（Stack容器跟Positioned子组件）'),
      ),
      body: new ConstrainedBox(
        constraints: BoxConstraints.expand(),// 通过约束盒子将容器铺满整个屏幕
        child: new Stack(
          alignment: Alignment.center,
          children: <Widget>[
            new Positioned(
              top: 10.0,
              child: new Text('Stack容器内的组件在没有定位的方向上会按照Stack设置的对齐方式排布'),
            ),
            new Container(
              child: new Text('我没有任何定位'),
            ),
            new Positioned(
              left: 18.0,
              child: new Text('我只有左定位'),
            ),
            new Positioned(
              top: 38.0,
              child: new Text('我只有上定位'),
            )
          ],
        ),
      ),
    );
  }
}